<?php
$loginwarning = '';


if($_POST['submitlogin']){
	$un = $_POST['username'];
	$pw = $_POST['password'];
	$loginresult = mysql_query("select * from tbl_members where username='$un' and password='$pw' and active<>'0' ") or die (mysql_error());
	if($logrow = mysql_fetch_array($loginresult)){
		$memberid = $logrow['id'];
		$email = $logrow['email'];
		$username = $logrow['username'];
		$firstname = $logrow['firstname'];
		$lastname = $logrow['lastname'];
		$password = $logrow['password'];
		$active = $logrow['active'];
		$bpoints = $logrow['bpoints'];
		if($password != $pw){
			$loginwarning = "Incorrect password, please try again.";
		}else{
				$_SESSION['memberid'] = $memberid;
				$_SESSION['memberemail'] = $email;
				$_SESSION['membername'] = $firstname.' '.$lastname;
				$_SESSION['username'] = $username;
				header('Location: index.php');
		}
 	}else{
		$loginwarning = "Invalid account, please try again. ";
	}
}


?>
<?php if($_SESSION['username']){ echo ' 	<span style=" font-size:12px; font-family:arial;  color:#ffffff">Welcome <b>'.$_SESSION['membername'].'</b> &nbsp; &bull; &nbsp; <a href="my-reservations.php" class="topmenu">View My Reservations</a> &nbsp; &bull; &nbsp; <a href="my-account.php" class="topmenu">My Account</a> <br /></span>'; } else { ?>
        <form name="formlogin" method="post">
        <strong></strong>
        <font face = "Arial" size = "2px">Username:</font>
        <input type="text" name="username" value="" style="width:116px; border:dotted 1px #FF0000; font-size:11px; color:#666666" onfocus="if (value == 'Username') {value =''}" onblur="if (value == '') {value = 'Username'}" />
         <font face = "Arial" size = "2px">Password:</font>
         <input type="password" name="password" value="" style="width:116px; border:dotted 1px #FF0000; font-size:11px; color:#666666" onfocus="if (value == 'Password') {value =''}" onblur="if (value == '') {value = 'Password'}" />
         <input name="submitlogin" type="submit" value="LOGIN" style="width:80px; height:22px; font-size:11px " /><br />
        <? echo '<span style=" font-size:12px; font-family:arial;  color:#ffffff">'.$loginwarning.'</span>'; ?>
    </form>
        <?php }?>
